<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>set方法</title>
</head>

<body>
  <div id="app">
    <p v-for='(item,index) in arr' :key='index'>{{item}}</p>
    <p>{{obj.name}}</p>
    <p>{{obj.age}}</p>
    <p>{{obj.gender}}</p>
  </div>
  <script src="./js/vue.js"></script>
  <script>
    var vm = new Vue({
      el: '#app',
      data: {
        arr: ['Tom', 'jerry', 'spike'],
        obj: {
          name: 'lishi',
          age: 18,
          gender: 'meal'
        }
      },
      methods: {
      }
    })
    // 对数组
    // vm.arr[1] = 'saaa' // 没有响应式
    // Vue.set(vm.arr, 1, 'gege')
    // vm.$set(vm.arr, 1, 'hahah')

    // 对对象
    // vm.obj['info'] = 'haha'
    // vm.$set(vm.obj, 'name', 'afasdf')
    Vue.set(vm.obj, 'name', 'afasdf')

  </script>
</body>

</html>